package com.lagou.edu.service.impl;

import com.lagou.edu.dao.AuthCodeDao;
import com.lagou.edu.entity.AuthCode;
import com.lagou.edu.service.AuthCodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @Author: yeqingyun
 * @Date: 2020/11/20 17:03
 */
@Service
@RequiredArgsConstructor
public class AuthCodeServiceImpl implements AuthCodeService {

    private final AuthCodeDao authCodeDao;

    @Override
    public void create(AuthCode authCode) {
        authCodeDao.save(authCode);
    }

    @Override
    public Optional<AuthCode> getByEmail(String email) {
        return Optional.ofNullable(authCodeDao.findByEmail(email));
    }
}
